Software Development
Functions and Memory Management in C
Functions and Memory in C: Allocating Memory on the Heap
Functions and Memory in C: Getting Started with Functions
Functions and Memory in C: Getting Started with Pointers
Functions and Memory in C: Leveraging Pointers with Arrays & Functions
Functions and Memory in C: Using Variable Scopes, Storage Classes, & Structs

Functions and Memory in C: Allocating Memory on the Heap

Course Number:
it_cpdtmmdj_05_enus
Lesson Objectives

Functions and Memory in C: Allocating Memory on the Heap

  • discover the key concepts covered in this course
  • contrast stack and heap memory
  • use malloc() to allocate memory on the heap
  • use the free() method to free stack memory that is not allocated
  • allocate space for arrays using malloc()
  • return pointers to heap locations from functions
  • distinguish between dangling memory and memory leaks
  • contrast malloc(), calloc(), and realloc()
  • create pointers on struct objects
  • create pointer fields in structs
  • summarize the key concepts covered in this course

Overview/Description
C programmers can commonly use two kinds of memory: stack and heap. While stack memory is used to store local variables and is fully managed by C, it does have major limitations that are mitigated by heap memory. In this course, you will compare stack and heap memory, exploring the advantages and limitations of each. Then, you will allocate memory using the malloc() function and deallocate memory using free(). Next, you will examine dangling memory issues that can cause potentially dangerous security issues. You will also explore other common allocation functions like calloc() to zero out memory and realloc() to help when you underestimate how much memory an array will require. Finally, you will focus on pointers to struct objects. After completing this course, you'll be able to allocate memory malloc, calloc, and realloc; free memory; use pointers to structs; and avoid problems related to dangling pointers and memory leaks.

Target

Prerequisites: none

Functions and Memory in C: Getting Started with Functions

Course Number:
it_cpdtmmdj_01_enus
Lesson Objectives

Functions and Memory in C: Getting Started with Functions

  • discover the key concepts covered in this course
  • define and list the advantages of functions
  • recognize the process and syntax of a function
  • convert strings to integers using the atoi() library function
  • demonstrate how to use different utility functions
  • create user-defined functions
  • return values and accept input arguments in functions
  • contrast the declaration and definition of a function
  • summarize the key concepts covered in this course

Overview/Description
In C, as in other programming languages, the term function refers to a named and parameterized block of code that can be invoked repeatedly. Functions allow monolithic programs to be split into modular chunks, greatly facilitating code reuse and simplifying and improving the logical structure of programs. Explore C functions and learn how they are defined, declared, and invoked. Next, move on to built-in functions and discover how to convert strings to integers, floats, or longs. Then, you will create your own functions to accept input arguments from and return output to the invoker of the function. Finally, you will study the difference between the declaration and the definition of a function. After completing this course, you'll be able to define and invoke functions, understand implicit and explicit function declarations, and use both library functions and user-defined functions.

Target

Prerequisites: none

Functions and Memory in C: Getting Started with Pointers

Course Number:
it_cpdtmmdj_03_enus
Lesson Objectives

Functions and Memory in C: Getting Started with Pointers

  • discover the key concepts covered in this course
  • recall the memory layout of C
  • recognize pointers and demonstrate how to use them
  • reference the value in the block of memory referred to by the pointer
  • create basic pointers
  • access memory locations and the values stored in them
  • modify variables using pointers
  • create pointers from other pointers
  • dereference pointers and view addresses of variables
  • work with the NULL type
  • summarize the key concepts covered in this course

Overview/Description
One of the main reasons C retains its relevance after 50 years is the level of interaction between the programmer and the memory which C allows for. While more modern languages such as Python manage the memory under-the-hood, C allows the user to control all aspects of memory management. At the heart of C’s memory management capabilities lie pointers. Begin this course focusing on memory allocation layout and the concepts of stack and heap memory. Then, explore pointers to learn how to view the memory location referenced by the pointer and how to dereference a pointer to view the data at the referenced address or modify data stored at the memory location being pointed to. Finally, use the NULL keyword as both a value and a pointer to the non-existent memory address of 0. Upon completion of this course, you'll be able to use referencing and dereferencing operators in C and properly test for and use NULL values.

Target

Prerequisites: none

Functions and Memory in C: Leveraging Pointers with Arrays & Functions

Course Number:
it_cpdtmmdj_04_enus
Lesson Objectives

Functions and Memory in C: Leveraging Pointers with Arrays & Functions

  • discover the key concepts covered in this course
  • illustrate how arrays are pointers
  • create an array and access it through its pointer
  • distinguish the finer points of arrays and pointers
  • outline key concepts of pointer arithmetic for arrays
  • view the address of elements in an array using pointer arithmetic
  • create a pointer to view array elements
  • pass pointers into functions
  • pass arrays into functions
  • return pointers from functions
  • summarize the key concepts covered in this course

Overview/Description
Pointers are some of the most important building-blocks of C and are used with a variety of data types. In particular, pointers have a special relationship with arrays, because an array is effectively a pointer to a contiguous block of memory used to hold elements of a specific type. In this course, you will create both arrays and pointers to those arrays. Next, take a deeper dive into the nuances of arrays and pointers and discover how to use pointer arithmetic as a method of viewing array elements. Finally, explore passing pointers and arrays into functions. After completing this course, you'll be able to leverage the equivalence between pointers and arrays, use pointer arithmetic, and return pointers from functions.

Target

Prerequisites: none

Functions and Memory in C: Using Variable Scopes, Storage Classes, & Structs

Course Number:
it_cpdtmmdj_02_enus
Lesson Objectives

Functions and Memory in C: Using Variable Scopes, Storage Classes, & Structs

  • discover the key concepts covered in this course
  • create file scope variables
  • work with variable scopes
  • recall input argument scoping
  • redefine variables in different scopes
  • recognize storage classes
  • create static variables
  • use external variables
  • use the static and extern keywords with functions
  • differentiate between pass-by-value and pass-by-reference
  • create and instantiate structs
  • work with unions
  • create enums
  • summarize the key concepts covered in this course

Overview/Description
A vital part of programming is being able to reuse codes in an efficient and effective way. Using variable scopes, storage classes, different user-defined types like structs, unions and enums allow programmers to scale their programs and create meaningful structures. Begin by exploring variable scope and learn how to input argument scoping and redefine variables. Discover how to work with storage classes and access them in file scope, local scope, and across files. Finally, take a look at different user-defined types in C. Upon completion of this course, you will be able to confidently leverage variable scopes and storage classes to define values, scope, and visibility.

Target

Prerequisites: none

Close Chat Live